#include "widget.h"
#include "ui_widget.h"
#include <QDebug>
Widget::Widget(QWidget *parent)
    : QWidget(parent)
    , ui(new Ui::Widget)
{
    ui->setupUi(this);

    connect(ui->pushButton,&QPushButton::clicked,this,&Widget::myHandleClick1);

}

Widget::~Widget()
{
    delete ui;
}

void Widget::myHandleClick1()
{
    this->setWindowTitle("标题1");
    qDebug()<<"myHandleClick1()";
}


void Widget::myHandleClick2()
{
    this->setWindowTitle("标题2");
    qDebug()<<"myHandleClick2()";
}


void Widget::on_pushButton_2_clicked()
{
    //先断开pushButton原来的信号槽
    //如果没有disconnect，就会导致一个信号对应2个槽
    disconnect(ui->pushButton,&QPushButton::clicked,this,&Widget::myHandleClick1);

    //重新连接信号和槽
    connect(ui->pushButton,&QPushButton::clicked,this,&Widget::myHandleClick2);
}
